<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link href="../../assets/css/maincss.css" rel="stylesheet" />
<link href="../../assets/css/but.css" rel="stylesheet" />
</head>
<!-- Bootstrap -->
<link href="${pageContext.request.contextPath}/javascript/bootstrap/css/bootstrap.css" rel="stylesheet">
<link rel="stylesheet" href="${pageContext.request.contextPath}/javascript/table/bootstrap-table.css">
<script src="${pageContext.request.contextPath}/javascript/jQuery-1.12.4.js"></script>
<script src="${pageContext.request.contextPath}/javascript/bootstrap/js/bootstrap.js"></script>
<script src="${pageContext.request.contextPath}/javascript/table/bootstrap-table.js"></script>
<script src="${pageContext.request.contextPath}/javascript/table/locale/bootstrap-table-zh-CN.js"></script>
<script type="text/javascript"
	src="../../javascript/My97DatePicker/WdatePicker.js"></script>
<body>

	<!-- 模态框里添加表格行的模态框 -->
	<table id="modalTr" style="display: none;" class="table table-hover">

		<tr id="tr">
			<td class="detailId" hidden>
				<input  class="form-control" type="text" name="detailID" value="0" readonly  />
			</td>
			<td>
				<select  class="form-control" id="products" name="products">
					<option value="0">选择商品</option>
				</select>
			</td>
			<td class="qua">
				<input  class="form-control" id="quantity" name="quantity" type="number"/>
			</td>
			<td class="dis">
				<select  class="form-control" id="discount" name="discount">
						<option value="0">不打折</option>
						<option value="0.95">95折</option>
						<option value="0.85">85折</option>
				</select>
			</td>
			<td>
				<a name="del" value="del" class="btn btn-danger del" >删除</a>
			</td>
		</tr>

	</table>
	<table id="modalTr2" style="display: none;" class="table table-hover">

		<tr id="tr">
			<td class="detailId" hidden>
				<input  class="form-control" type="text" name="detailID" value="0" readonly   />
			</td>
			<td>
				<select  class="form-control" id="products" name="products">
					<option value="0">选择商品</option>
				</select>
			</td>
			<td class="qua">
				<input  class="form-control" id="quantity" name="quantity" type="number"/>
			</td>
			<td class="dis">
				<select  class="form-control" id="discount" name="discount">
						<option value="0">不打折</option>
						<option value="0.95">95折</option>
						<option value="0.85">85折</option>
				</select>
			</td>
			<td>
				<a name="del" class="btn btn-danger del" value="del" >删除</a>
			</td>
		</tr>

	</table>



	<!-- 模态框  -->
	<div id="myModal" class="modal fade" tabindex="-1" role="dialog"
		aria-labelledby="gridSystemModalLabel">
		<div class="modal-dialog modal-lg" role="document">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal"
						aria-label="Close">
						<span aria-hidden="true">&times;</span>
					</button>
					<h4 class="modal-title" id="gridSystemModalLabel">[修改/删除]订单详情</h4>
				</div>
				<div class="modal-body">
						<form id="myform"  class="navbar-form navbar-center" role="search">
							<div>
								<div class="form-group">
									订单编号:<input  class="form-control" id="orderId" name="orderId" type="text" readonly /> 
								</div>
								<div class="form-group" >
									下单时间:<input  class="form-control" id="orderTime" name="orderTime" type="text"  readonly> 
								</div>
								<div class="form-group">
									<select  class="form-control" id="customers" name="customers">
										<option value="0">选择客户</option>
									</select> 
								</div>
								<div class="form-group">
									<select  class="form-control" id="employees" name="employees">
										<option value="0">选择员工</option>
									</select>
								</div>
							</div>
							<br />
							<table id="modalTable" name="table1" class="table table-hover">
								<tr>
									<td hidden>id</td>
									<td>产品名称</td>
									<td>数量</td>
									<td>是否折扣</td>
									<td>操作</td>
								</tr>
								
								<tr >
	    	
	    						</tr>
							</table>
						</form>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-danger" value="删除" name="delAll">删除订单</button>
					<button type="button" class="btn btn-default" value="增加" name="add">增加数据</button>
					<button type="button" class="btn btn-primary" value="修改" name="sub">提交修改订单</button>
				</div>
			</div>
			<!-- /.modal-content -->
		</div>
		<!-- /.modal-dialog -->
	</div>
	<!-- /.modal -->
	<!-- 模态框 end -->
	
	<h3>订单管理</h3>
	
	<form id="searcFrom" class="navbar-form navbar-left" role="search">
		<input type="text" id="currengPage" name="currengPage" value="1" hidden />
		<input type="text" id="pageSize" name="pageSize" value="5" hidden />
		<div class="form-group">
			<input type="text" class="form-control" id="orderID" name="orderID" placeholder="订单编号">
		</div>
		<div class="form-group">
			<input type="text" class="form-control" id="orderDate" name="orderDate" placeholder="下单时间"  onclick="WdatePicker()">
		</div>
		<div class="form-group">
			<select name="customers" id="customers" class="form-control">
				<option value="0">选择客户</option>
			</select>
		</div>
		<div class="form-group">
			<select name="employees" id="employees" class="form-control">
				<option value="0">选择员工</option>
			</select>
		</div>
		<button type="button" class="btn btn-default" onclick="searchOrder()">查询</button>
		
		<a href="addOrder.jsp" class="btn btn-success">添加订单</a>
	</form>
	<table id="table1" class="table table-hover" style="text-align: center;">
	    <!-- <tr>
	        <td>订单id</td>
	        <td>下单时间</td>
	        <td>客户</td>
	        <td>员工</td>
	        <td>操作</td>
	    </tr> -->
	   <!--  <tr >
	    	
	    </tr> -->
	</table>
</body>

<script type="text/javascript">
var count = 0;
var $modalTr = "<tr>"+
"<td>"+
"<select id='products' name='products'>"+
"           <option value='0'>选择商品</option>"+
"       </select>"+
"   </td>"+
"   <td>"+
"       <input id='quantity' name='quantity' type='number' />"+
"   </td>"+
"   <td>"+
"       <select id='discount' name='discount'>"+
"           <option value='0'>不打折</option>"+
"           <option value='0.95'>95折</option>"+
"           <option value='0.85'>85折</option>"+
"       </select>"+
"   </td>"+
"   <td>"+
"       <button name='del' value='del' class='but red'>删除</button>"+
"   </td>"+
"</tr>";


	$(function(){
		// 在页面加载完成时 加载此方法 
		// findOrders();
		// showEditDetails();
	});
	
	// 
	var jsonPage = null;
	var totalPages = 0;
	
	//ajax 查询出订单数据[分页]
/* 	function findOrders(op){
		
		if(jsonPage != null && op == 1 && jsonPage.currentPage == 1){
			return 0;
		} else if(jsonPage != null && op == 2 && jsonPage.currentPage == totalPages){
			return 0;
		}
		
		
		$.ajax({
			type: "GET",
			url: "OrderServlet",
			data : {
				"op" : "showAllOrders",
				"currentPage" : $("#currengPage").val(),
				"pageSize" : $("#pageSize").val()
			},
			dataType: "JSON",
			success: function(pageResult){
				// alert(pageResult);
				$("#currengPage").val(pageResult.currentPage);
				$("#pageSize").val(pageResult.pageSize);
				//
				jsonPage = pageResult;
				totalPages = parseInt((pageResult.total + pageResult.pageSize - 1) / pageResult.pageSize);
				
				// 分页查询之前, 清除表格数据
				$("#table1 tr:not(:first):not(:last)").remove();
				
				var arr = pageResult.list;
				for(var i = 0 ; i < arr.length ; i++){
					var $tr = "<tr>"+
							        "<td>"+arr[i].orderID+"</td>"+
							        "<td>"+arr[i].orderDate+"</td>"+
							        "<td>"+arr[i].customer.customerName+"</td>"+
							        "<td>"+arr[i].employee.empName+"</td>"+
							        "<td>"+
							        // "   <button id='"+arr[i].orderID+"' onclick='showDetails(this)' class='but green' style='width:65px;'>订单详情</button>"+
							        "<button id='"+arr[i].orderID+"' type='button' class='btn btn-info btn-sm' data-toggle='modal' onclick='showEditDetails(this)' data-target='#myModal'>订单详情</button>"+
							        "</td>"+
				    		  "</tr>";
				    $($tr).insertBefore("tr:last");
				    
				    // 向订单详情按钮 加一个自定义属性 [添加orderID]
				    // $("button[name='showDetails']").attr("id",arr[i].orderID);
				}
				
				// 添加分页
				var $page = "<td colspan='5'><a href='#' onclick='upPage()'>[上一页]</a>"
						+ "&nbsp;&nbsp;&nbsp;&nbsp;" 
						+ "当前第"+ pageResult.currentPage + "页" 
						+ "&nbsp;&nbsp;" 
						+ "共"+ pageResult.total + "条数据" 
						+ "&nbsp;&nbsp;" 
						+ "共"+ totalPages + "页" 
						+ "&nbsp;&nbsp;&nbsp;&nbsp;"
						+ "<a href='#' onclick='nextPage()'>[下一页]</a></td>";
				
				$("tr:last").html($page);
				
			},
			error:function(){}
		});
	} */
	
	// 点击跳转到订单详细
	function showDetails(obj){
		// alert(obj.id);
		location.href = "showOrderDetails.jsp?orderID="+obj.id;
	}
	
	
	
	// 向模态框添加初始数据
		$.ajax({
			type: "GET",
			url: "OrderDetailServlet",
			data : "op=readyEditDetail",
			dataType: "JSON",
			success: function(allResult){
				// alert(allResult);
				// 员工
				
				var $empArr = allResult[0];
				for(var i = 0;i < $empArr.length;i++){
					$("select[name='employees']").append("<option value='"+$empArr[i].empID+"'>"+$empArr[i].empName+"</option>");
				}
				// 客户
				var $custArr = allResult[1];
				for(var i = 0;i < $custArr.length;i++){
					$("select[name='customers']").append("<option value='"+$custArr[i].customerID+"'>"+$custArr[i].customerName+"</option>");
				}
				// 商品
				var $prodArr = allResult[2];
				for(var i = 0;i < $prodArr.length;i++){
					$("select[name='products']").append("<option value='"+$prodArr[i].productId+"'>"+$prodArr[i].productName+"</option>");
				}
			},
			error:function(){}
		});
	
	
	
	
	// 点击跳出模态框 准备修改的数据
	function showEditDetails(obj){
		// alert(obj.id);
		// alert(obj.value);
		var orderId = obj.id; 
		$.ajax({
			type: "GET",
			url: "OrderDetailServlet",
			data : {
				"op" : "showDetailByOrderID",
				"orderID" : orderId
			},
			dataType: "JSON",
			success: function(detailResult){
				// alert(detailResult);
				
				$("#myModal input[name='orderId']").val(detailResult[0].order.orderID);		// 订单id
				$("#myModal input[name='orderTime']").val(detailResult[0].order.orderDate);	//订单时间
				$("#customers").find("option[value='"+detailResult[0].order.customer.customerID+"']").prop('selected',true);	// 选定客户
				$("#employees").find("option[value='"+detailResult[0].order.employee.empID+"']").prop('selected',true);		// 选定员工
				
				// 查询之前, 清除表格数据
				$("#modalTable tr:not(:first):not(:last)").remove();
				
				var $detailNum = detailResult.length;
				for (var i = 0; i < $detailNum; i++) {
					$("#modalTr tr td select").attr("prod_id",detailResult[i].product.productId);
					$("#modalTr a[name='del']").attr("detail_id",detailResult[i].id);
					$("#modalTr tr").clone().insertBefore("#modalTable tr:last");
				}
				
				
				// 向表格添加数据 prod_id='"+detailResult[j].product.productId+"'
				for (var j = 0; j < $detailNum; j++) {
					// alert(detailResult[j].id);
					$("select[prod_id='"+detailResult[j].product.productId+"']").parent().siblings(".detailId").children().val(detailResult[j].id);
					
					$("select[prod_id='"+detailResult[j].product.productId+"']").find("option[value='"+detailResult[j].product.productId+"']").prop('selected',true);		// 选定
					// console.log($("select[prod_id='"+detailResult[j].product.productId+"']").parent().siblings("#qua").children().val());
					$("select[prod_id='"+detailResult[j].product.productId+"']").parent().siblings(".qua").children().val(detailResult[j].quantity);
					$("select[prod_id='"+detailResult[j].product.productId+"']").parent().siblings(".dis").children().find("option[value='"+detailResult[j].discount+"']").prop('selected',true);
				}
				
				
				
				
			},
			error:function(){}
		});
		// count = $("table[name=table1] tr:not(:first)").size();
		// alert(count+"===");
	}

	
// ------------------------------bootstrap-table----------------------------------

$(function () {

    //1.初始化Table
    var oTable = new TableInit();
    oTable.Init();
});

var TableInit = function () {
    var oTableInit = new Object();
    //初始化Table
    oTableInit.Init = function () {
        $('#table1').bootstrapTable({
            url: 'OrderServlet',         //请求后台的URL（*）
            method: 'get',                      //请求方式（*）
            pagination: true,                   //是否显示分页（*）
            queryParams: oTableInit.queryParams,//传递参数（*）
            sidePagination: "server",           //分页方式：client客户端分页，server服务端分页（*）
            pageNumber:1,                       //初始化加载第一页，默认第一页
            showRefresh: true,
            pageSize: 5,                       //每页的记录行数（*）
            pageList: [5, 10, 25, 50, 100],        //可供选择的每页的行数（*）
            columns: [{
                checkbox: true
            }, {
                field: 'orderID',
                title: '订单id'
            }, {
                field: 'orderDate',
                title: '下单时间'
            }, {
                field: 'customer.customerName',
                title: '客户'
            }, {
                field: 'employee.empName',
                title: '员工'
            }, {
                field: 'Desc',
                title: '操作',
                formatter : actionFormatter
            } ]
        });
    };

    //得到查询的参数
    oTableInit.queryParams = function (params) {
        var temp = {   //这里的键的名字和控制器的变量名必须一直，这边改动，控制器也需要改成一样的
            limit: params.limit,   //页面大小
            offset: params.offset,  //页码[忽略数]
            op : "searchOrderByCondition",
            'orderID' : $("#searcFrom input[name=orderID]").val(),
            'orderDate' : $("#searcFrom input[name=orderDate]").val(),
            'customers' : $("#searcFrom select[name=customers]").val(),
            'employees' : $("#searcFrom select[name=employees]").val()
        };
        return temp;
    };
    return oTableInit;
};


	function actionFormatter(value , row , index){
		// alert("value : "+value+"===row : "+row+"===index : "+index);
		return "<button id='"+row.orderID+"' type='button' class='btn btn-info btn-sm' data-toggle='modal' onclick='showEditDetails(this)' data-target='#myModal'>订单详情</button>";
	}
	
	
	
	
	
	
// ------------------------------bootstrap-table----------------------------------
	
	

	// 根据条件查询订单数据
	function searchOrder(){
		$('#table1').bootstrapTable('refresh',{
			'limit': '5',   //页面大小
            'offset': '0',  //页码[忽略数]
            'orderID' : $("#searcFrom input[name=orderID]").val(),
            'orderDate' : $("#searcFrom input[name=orderDate]").val(),
            'customers' : $("#searcFrom select[name=customers]").val(),
            'employees' : $("#searcFrom select[name=employees]").val()
		});
		$("#table1").bootstrapTable('refreshOptions',{
			pageNumber : 1
		});
	}
	searchOrder();
	
	/*function searchOrder(){
		$.ajax({
			type: "GET",
			url: "OrderServlet?op=searchOrderByCondition",
			data : $("#searcFrom").serialize(),
			dataType: "JSON",
			success: function(orderResult){
				// alert(orderResult);
				$("#currengPage").val(orderResult.currentPage);
				$("#pageSize").val(orderResult.pageSize);
				//
				jsonPage = orderResult;
				totalPages = parseInt((orderResult.total + orderResult.pageSize - 1) / orderResult.pageSize);
				
				// 分页查询之前, 清除表格数据
				$("#table1 tr:not(:first):not(:last)").remove();
				
				var arr = orderResult.list;
				for(var i = 0 ; i < arr.length ; i++){
					var $tr = "<tr>"+
							        "<td>"+arr[i].orderID+"</td>"+
							        "<td>"+arr[i].orderDate+"</td>"+
							        "<td>"+arr[i].customer.customerName+"</td>"+
							        "<td>"+arr[i].employee.empName+"</td>"+
							        "<td>"+
							        // "   <button id='"+arr[i].orderID+"' onclick='showDetails(this)' class='but green' style='width:65px;'>订单详情</button>"+
							        "<button id='"+arr[i].orderID+"' type='button' class='btn btn-info btn-sm' data-toggle='modal' onclick='showEditDetails(this)' data-target='#myModal'>订单详情</button>"+
							        "</td>"+
				    		  "</tr>";
				    $($tr).insertBefore("tr:last");
				    
				    // 向订单详情按钮 加一个自定义属性 [添加orderID]
				    // $("button[name='showDetails']").attr("id",arr[i].orderID);
				}
				
				// 添加分页
				var $page = "<td colspan='5'><a href='#' onclick='upPage()'>[上一页]</a>"
						+ "&nbsp;&nbsp;&nbsp;&nbsp;" 
						+ "当前第"+ orderResult.currentPage + "页" 
						+ "&nbsp;&nbsp;" 
						+ "共"+ orderResult.total + "条数据" 
						+ "&nbsp;&nbsp;" 
						+ "共"+ totalPages + "页" 
						+ "&nbsp;&nbsp;&nbsp;&nbsp;"
						+ "<a href='#' onclick='nextPage()'>[下一页]</a></td>";
				
				$("tr:last").html($page);
			}
		});
		
	}*/

	
	/* // 上一页
	function upPage(){
		if(jsonPage.currentPage > 1){
			$("input[id='currengPage']").val(jsonPage.currentPage - 1);
		}
		findOrders(1);
	}
	
	// 下一页
	function nextPage(){
		if(jsonPage.currentPage < totalPages){
			$("input[id='currengPage']").val(jsonPage.currentPage + 1);
			// alert($("input[id='currengPage']").val());
		}
		findOrders(2);
	}
 */
	
	// 全屏点击事件
	$(document).click(function(e) {
		var op = e.target.innerHTML;
		// alert(op);
		if (op == "增加数据") {
			$("#modalTr2 tr").clone().insertBefore("#modalTable tr:last");
			
		} else if (op == "删除") {
			
			// 删除订单-详情[有 id=0 通过方法删除][无 id=0 通过jQuery方法删除]
			// alert(e.target.getAttribute("detail_id")); // 获取标签上自定义的属性值
			var detailId = e.target.getAttribute("detail_id");
			
			if(parseInt(detailId) == 0){
				alert("已删除");
				$(e.target).parent().parent().remove();
				
			} else if(detailId == null){
				alert("已删除");
				$(e.target).parent().parent().remove();
				
			} else {
				// alert("方法删除======"+detailId);
				$.ajax({
					type: "POST",
					url: "OrderDetailServlet",
					data : {
						"op" : "delDetailByDetailId",
						"orderId" : $("input[name='orderId']").val(),
						"detailId" : detailId
					},
					// dataType: "JSON",
					success: function(delResult){
						// alert(delResult);
						if(delResult == "true"){
							alert("已删除-");
							$(e.target).parent().parent().remove();
						} else if(delResult == "false") {
							alert("删除失败-");
							 
						} else if(delResult == "removeOrder"){
							// 删除订单
							// ------------------测试代码---------------------------
							var count = $("#modalTable tr:not(:first)").size();
							// alert(count+"===");
							$(e.target).parent().parent().remove();
							
							
							// ------------------测试代码---------------------------
							var result = confirm("删除该商品列后,该订单即为空订单,是否删除该订单?");  
		    				if (result) {  
								removeOrderById();
		    				} else {
		    					// return false;
		    					// alert("----");
		    				}
		    				window.location.reload();
						}
					},
					error:function(){}
				});
			}

				
	
			
		} else if (op == "提交修改订单") {
			// 修改订单详情
			// 数据提交前判断是否有重复数据
			var f = false;
			// var arr = $("select[id='products']");
			var arr = $("#modalTable select[id='products']");
			for(var i = 0; i < arr.length; i++){
				console.log(arr[i].value);
				for (var j = i + 1; j < arr.length; j++) {
					if(arr[i].value == arr[j].value){
						f = true;
						break;
					}
				}
			}
			if (f) {
				alert("所选商品中有重复,请重新选择.");
			} else {
				
				if(clickAllData()){
					// alert("提交");
					$.ajax({
						type: "POST",
						url: "OrderDetailServlet?op=doEditOrderDetail",
						data : $("#myform").serialize(),
						// dataType: "JSON",
						success: function(modifyResult){
							// alert(modifyResult);						
							if(modifyResult == "true"){
								alert("修改成功!");
								window.location.reload();
							} else {
								alert("修改失败!");
								window.location.reload();
							}
						},
						error:function(){}
					});
				} else {
					alert("有数据未正常填写,请重新输入.");
				}
				
			
				
			}
			
		} else if(op == "删除"){
			alert("删除");
		} else if(op == "删除订单"){
			// 还有订单详情数据, 先删除订单-详情数据,在删除订单
			var result = confirm("确定删除该订单?");  
		    if (result == true) {  
		        removeOrderById();
		        alert("订单已删除");  
		    }
		    window.location.reload();
		}
	});

	
	// 点击删除事件
	/* function delDetail(obj){
		var detailId = obj.getAttribute("detail_id");
		
		if(parseInt(detailId) == 0){
			alert("已删除");
			$(e.target).parent().parent().remove();
			
		} else if(detailId == null){
			alert("已删除");
			$(e.target).parent().parent().remove();
			
		} else {
			// alert("方法删除======"+detailId);
			$.ajax({
				type: "POST",
				url: "OrderDetailServlet",
				data : {
					"op" : "delDetailByDetailId",
					"detailId" : detailId
				},
				// dataType: "JSON",
				success: function(delResult){
					// alert(delResult);
					if(delResult == "true"){
						alert("已删除");
						// $(e.target).parent().parent().remove();
					}
				},
				error:function(){}
			});
		}
	}
	 */
	
	 
	 // 封装删除订单方法
	 function removeOrderById(){
		 // alert("123");
		 $.ajax({
				type: "POST",
				url: "OrderServlet",
				data : {
					"op" : "delOrderById",
					"orderId" : $("input[name='orderId']").val()
				},
				// dataType: "JSON",
				success: function(delResult){
					if(delResult == "true"){
						alert("订单删除成功!");
						window.location.reload();
					} else if(delResult == "false"){
						alert("订单删除失败!");
					}
				},
				error:function(){}
			});
	 }
	
	
	 
	 
		// 校验表单
		function clickAllData(){
			
			
			for (var i = 0; i < $("#modalTable input[name='quantity']").length; i++) {
				if($("#modalTable input[name='quantity']")[i].value <= 0 || $("#modalTable input[name='quantity']")[i].value == null || $("#modalTable input[name='quantity']")[i].value == "" || !/^\d+$/.test($("#modalTable input[name='quantity']")[i].value)){
					alert("请正确填写数量值");
					return false;
				}
			}
			
			for (var i = 0; i < $("#myform #customers").length; i++) {
				if($("#myform #customers")[i].value == 0 || $("#myform #customers")[i].value == null || $("#myform #customers")[i].value == ""){
					alert("请选择客户");
					return false;
				}
			}
			
			for (var i = 0; i < $("#myform #employees").length; i++) {
				if($("#myform #employees")[i].value == 0 || $("#myform #employees")[i].value == null || $("#myform #employees")[i].value == ""){
					alert("请选择客户");
					return false;
				}
			}
			
			for (var i = 0; i < $("#modalTable #products").length; i++) {
				if($("#modalTable #products")[i].value == 0 || $("#modalTable #products")[i].value == null || $("#modalTable #products")[i].value == ""){
					alert("请选择商品");
					return false;
				}
			}
			
			return true;
		}

	 
	 
	 
	 
	 
	 
	 
	 
	
		
		/* $("#myModal").on("show.bs.modal",function(){
			// alert("模态框打开");
			$("#customers").find("option[value='0']").removeAttr('selected');
		}); */
		/* $("#myModal").on("hide.bs.modal",function(e){
			// alert($(e.target).find("#orderId").val()+" ====");
			// alert("11231231");
			var result = confirm("该订单为空订单,是否删除该订单?");  
			if (result) {
				removeOrderById();
				window.location.reload();
			} else {
				$("#table1 tr:not(:first):not(:last)").remove();
			}
	}); */
</script>

</html>